﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;

public static class test   
{   
	/*
      ** 测试 ******************************************************
	*/
	[DllImport ("__Internal")]    
	private static extern void _showTestView(string msg);  

	[DllImport ("__Internal")]    
	private static extern void _showCompressView();  

	public static void showTestView (string msg)  
	{  
		_showTestView(msg);  
	}  
	public static void showCompressView ()  
	{  
		_showCompressView();  
	}  
	/*
      ** 调取摄像功能  ******************************************************
	*/
	[DllImport ("__Internal")]    
	private static extern void IOS_OpenCamer();  

	[DllImport ("__Internal")]    
	private static extern void IOS_OpenAlbum();  

	[DllImport ("__Internal")]    
	private static extern void IOS_OpenPhoto();  

	public static void OpenCamera()
	{
		IOS_OpenCamer ();
	}
	public static void OpenAlbum()
	{
		IOS_OpenAlbum ();
	}
	public static void OpenPhoto()
	{
		IOS_OpenPhoto ();
	}

	/*
      ** 图片转换成base64  ******************************************************
	*/
	/// <summary>
	/// 将ios传过的string转成u3d中的texture
	/// </summary>
	/// <param name="base64"></param>
	/// <returns></returns>
	public static Texture2D Base64StringToTexture2D(string base64)
	{
		Texture2D tex = new Texture2D (4, 4, TextureFormat.ARGB32, false);
		try
		{
			byte[] bytes = System.Convert.FromBase64String(base64);
			tex.LoadImage(bytes);
		}
		catch(System.Exception ex)
		{
			Debug.LogError(ex.Message);
		}
		return tex;
	}   





}   




